package com.xxpt.common.auth;

import com.xxpt.common.exception.ErrorCode;

/**
 * 异常信息
 *
 * @Author masl - 2018/8/20 11:30
 */
public enum ValidationErrorCode implements ErrorCode {

    SUCCESS("200", "操作成功！"),
    ERROR_NETWORK("201", "系统异常"),
    ERROR_ILLEGAL_REQUEST("202", "非法请求"),
    ERROR_DATA_INFO("203", "数据异常"),
    ERROR_DECRYPT_DATA("204", "解密失败"),
    ERROR_REPEATED_SUBMIT("205", "请勿重复提交"),
    ERROR_REQUEST_FAIL("206", "接口请求失败"),
    SYSTEM_MAINTAIN("207", "系统维护中..."),
    ADMIN_NO_LOGIN("208", "需要管理员登录..."),
    USER_NOT_LOGIN("209", "用户未登录或认证失效"),
    NO_AUTH_INTERFACE_ACCESS("210", "您没有该接口的访问权限"),
    TOKEN_EXPIRED("211", "用户登录认证失效，token 已失效"),
    TOKEN_NON_EXIST("212", "用户登录认证失效，token 不存在"),
    DATA_NOT_EXISTS("213", "数据不存在"),
    HANDEL_DATA_NOT_EXISTS("214", "没有需要处理的数据"),
    INTERNAL_SERVER_ERROR("500", "服务器内部错误"),
    SYSTEM_INTERNAL_SERVER_ERROR("501", "系统内部错误"),
    CAN_NOT_FOUND_SERVER("504", "找不到服务器"),
    ROUTE_TIME_OUT("505", "路由超时"),
    OTHER_FEIGN_ERROR("510", "未知节点异常"),

    // 通用错误码 3000 - 3500
    ERROR_REQUIRED("3000", "缺少必要的参数"),
    ERROR_PARAM_ILLEGAL("3001", "参数信息不合法"),
    ERROR_STRING_CAN_NOT_BE_EMPTY("3002", "字符串不能为空"),
    ERROR_FILE_TOO_MAX("3003", "文件大小超过限制"),
    ERROR_FILE_FORMAT("3004", "文件格式不正确"),
    ERROR_FILE_IS_EMPTY("3005", "文件不能为空"),
    ID_NUMBER_NOT_EXIST("3006", "身份证号不存在"),
    CERT_NUMBER_NOT_EXIST("3007", "证书编号号不存在"),
    ERROR_ID_ILLEGAL("3010", "身份证号不正确"),
    ERROR_PHONE_ILLEGAL("3011", "手机号格式不正确"),
    UPLOAD_FILE_ISEMPTY("3012", "上传文件为空"),
    FILE_EXT_ERROR("3013", "文件格式错误！"),
    EXCEL_DATA_TOO_LARGE_ERROR("3014", "您上传的文件过大，请重新导入！"),
    REGISTER_NOT_EXIST("3015", "注册项不存在或已删除"),
    VERIFY_CODE_EXPIRED("3016", "验证码已失效"),
    VERIFY_CODE_INCORRECT("3017", "验证码不正确"),
    IMPORT_TEMPLATE_ERROR("3018", "导入模板格式错误"),
    IMPORT_EXCEL_HEAD_VERIF_ERROR("3019", "表头校验失败"),


    // 用户模块错误码 4000-4400
    ACCOUNT_OR_PWD_ERROR("4000", "账号或密码错误"),
    ACCOUNT_DELETED("4001", "账号已删除或不存在"),
    ACCOUNT_LEAVE("4002", "该账号学员已离职"),
    ACCOUNT_MERGING("4003", "账号正在合并"),
    ACCOUNT_INFO_ERROR("4004", "账号数据错误"),
    SYS_AREA_BIZ_DELETED_OR_DISABLED("4005", "地区业务配置已删除或被禁用"),
    ACCOUNT_IDENTITY_NOT_MATCH("4006", "用户身份不符"),
    TEL_OR_EMAIL_IS_NOT_VALIDATE("4007","您输入的预留信息不正确,请重新输入"),
    VALIDATE_CODE_IS_INPUT_ERROR("4008","验证码输入错误，请重新输入"),
    VALIDATE_CODE_IS_NOT_VALIDATE("4009","验证码已失效，请重新获取验证码"),
    USER_NAME_REPEAT("4010","名称重复"),

    ;


    private String code;
    private String desc;

    ValidationErrorCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return desc;
    }

    public ValidationErrorCode setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static ValidationErrorCode getEnum(String code) {
        for(ValidationErrorCode v : values())
            if(v.getCode().equals(code)) return v;
        throw new IllegalArgumentException();
    }
}
